﻿using System;
using EasyNetQ;

namespace Aquarinum.Base.Infrastructure.EventBus.Default
{
    [Queue("MQErrorQueue", ExchangeName = "MQErrorExchange")]
    public class DefaultMqExcepotionMessage
    {
        public DefaultMqExcepotionMessage(string message, Exception ex)
        {
            ErrorTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            if (ex != null)
            {
                ErrorInfo = ex?.Message;
                ErrorSource = ex?.Source;
                ErrorType = ex?.GetType().ToString();
                ErrorFunction = ex?.TargetSite.ToString();
                ErrorTrace = ex?.StackTrace;
            }


            Message = message;
        }

        public string Message { get; set; } 
        public string ErrorTime { get; set; }
        public string ErrorInfo { get; set; } = string.Empty;
        public string ErrorSource { get; set; } = string.Empty;
        public string ErrorType { get; set; } = string.Empty;
        public string ErrorFunction { get; set; } = string.Empty;
        public string ErrorTrace { get; set; } = string.Empty;
    }
}